<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>方维网站后台管理系统_深圳网站建设</title>
    <meta name="author" content="深圳方维网络科技有限公司 http://www.szfangwei.cn" />
    <import type="css" file="admin/css/index" />
    <import type="js" file="common/jquery171min" />
    </head>
<body>
<div class="search"  style="width:780px;" >
    <form method="get" action="">
        商品标题：<input type="text" name="title" id="title" value="{$title}" class="input1" />&nbsp;&nbsp;
       <select name="cat_id" id="cat_id" class="sel1">
            <option value="">所有类别</option>
            <volist name="cat_list" id="item_c">
                <option value="{$item_c.cat_id}">{$item_c.cat_name}</option>
            </volist>
        </select>&nbsp;&nbsp;
        <select name="brand_id" id="brand_id" class="sel1">
            <option value="">所有品牌</option>
            <volist name="brand_list" id="item_b">
                <option value="{$item_b.brand_id}">{$item_b.brand_name}</option>
            </volist>
        </select>&nbsp;&nbsp;
        <select name="status" id="status" class="sel1">&nbsp
            <option value="">所有状态</option>
            <option value="1">上架</option>
            <option value="2">下架</option>
        </select>
        &nbsp;<input type="submit" value="搜索" class="btn_search" />
        <input type="hidden" name="p" value="1" />
        <script type="text/javascript">
            $(function(){
                $('#cat_id').val('{$cat_id}');
                $('#brand_id').val('{$brand_id}');
                $('#status').val('{$status}');
             })
        </script>
        <input type="hidden" name="block_id" value="{$block_id}" />
        <input type="hidden" name="style_id" id="style_id" value="{$style_id}" />
        <input type="hidden" name="style_item_id" id="style_item_id" value="{$style_item_id}" />
    </form>
</div>
<div class="list">
    <table class="table_list" style="width:800px;">
        <thead><tr>
                <td width="30px">选择</td>
                <td>商品标题</td>
                <td width="100px">所属类别</td>
                <td width="80px">所属品牌</td>
                <td width="60px">状态</td>
            </tr>
        </thead>
        <tbody>
        <foreach name="list" item="list">
            <tr>
               <if condition="in_array($list['goods_id'],$arr_tuijian)">
               <td><input type="checkbox" name="selid" disabled="disabled" value="{$list.goods_id}" /></td>
               <else />
               <td><input type="checkbox" name="selid" value="{$list.goods_id}" /></td>
               </if>
               <td style="text-align:left;line-height:18px;">
                    <a href="{:U('Home/Goods/index',array('id'=>$list['goods_id']))}" target="_blank" style="font-weight:bold;">{$list.goods_name}</a>
                </td>
                <td>{$list.cat_name}</td>
                <td>{$list.brand_name}</td>
                <td>{$list.status}</td>
            </tr>
        </foreach>
        </tbody>
        <tfoot>
            <tr><td colspan="5"><input type="button" onclick="sel_goods()" class="btn_search" value="推荐已选产品" /></td></tr>
            <tr><td colspan="5"><div class="page">{$page}</div></td></tr>
        </tfoot>
    </table>
</div>
<input type="hidden" name="block_id" id="block_id" value="{$block_id}" />
<input type="hidden" name="style_id" id="style_id" value="{$style_id}" />
<input type="hidden" name="style_item_id" id="style_item_id" value="{$style_item_id}" />
<script src="__PUBLIC__/common/artDialog4.1.7/artDialog.source.js?skin=blue"></script>
<script src="__PUBLIC__/common/artDialog4.1.7/plugins/iframeTools.source.js"></script>
<script type="text/javascript">
    function sel_goods() {
        var block_id = $("#block_id").val();
        var style_id = $("#style_id").val();
        var style_item_id = $("#style_item_id").val();
        var s = ''; 
        $('input[name="selid"]:checked').each(function(){ 
            s += $(this).val()+','; 
        });
        if(s == '') {
            alert('请选择商品');
        } else {
            $.ajax({
                url:"{:U('IndexBlock/content_add_pro')}",
                cache:false,
                type:"POST",
                data:{block_id:block_id,style_id:style_id,style_item_id:style_item_id,goods_ids:s},
                success:function(val) {
                    if(val == 'success') {
                        var top = art.dialog.top;
                        top.document.location.reload();
                        var api = art.dialog.open.api;
                        api.close();
                    } else {
                        alert('添加出错');
                    }
                }
            })
        }
        
    }
</script>
</body>
</html>
